using System;
using System.Collections.Generic;
using System.Text;
using MicroFractal.iTunesBrowser.Business;

namespace MicroFractal.iTunesBrowser.Core.Device
{
    /// <summary>
    /// Representa un cambio en el progreso de descarga de un dispositivo.
    /// </summary>
    /// <param name="sender">Objeto que ejecuto el evento.</param>
    /// <param name="e">Informacion del evento.</param>
    public delegate void DownloadProgressEventHandler(object sender, DownloadProgressEventArgs e);

    /// <summary>
    /// Provee la informacion del evento <see cref="DownloadProgressEventHandler"/>.
    /// </summary>
    public class DownloadProgressEventArgs : EventArgs
    {

        #region Constructors

        public DownloadProgressEventArgs(int progress, Song downloadedSong, Song nextDownloadingSong)
        {
            _progress = progress;
            _downloadedsong = downloadedSong;
            _nextDownloadingSong = nextDownloadingSong;
        }

        #endregion

        #region Properties

        private int _progress;
        /// <summary>
        /// Obtiene el progreso de la tarea de descarga.
        /// </summary>
        public int Progress
        {
            get { return _progress; }
        }

        private Song _downloadedsong;
        /// <summary>
        /// Obtiene la cancion que se ha descargado.
        /// </summary>
        public Song DownloadedSong
        {
            get { return _downloadedsong; }
        }

        private Song _nextDownloadingSong;
        /// <summary>
        /// Obtiene la proxima cancion a descargar.
        /// </summary>
        public Song NextDownloadingSong
        {
            get { return _nextDownloadingSong; }
        }

        private bool _hasErrors;
        /// <summary>
        /// Obtiene si se produjeron errores en la descarga.
        /// </summary>
        public bool HasErrors
        {
            get { return _hasErrors; }
        }

        private Exception _error;
        /// <summary>
        /// Obtiene el error que de produjo en la descarga.
        /// </summary>
        public Exception Error
        {
            get { return _error; }
            internal set
            {
                _error = value;
                _hasErrors = value != null;
            }
        }


        #endregion

    }

}
